home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir24 / psi110g.zip / CONFIG.C < prev    next >
C/C++ Source or Header  |  1994-08-26  |  34KB  |  1,318 lines

  1. /* A collection of stuff heavily dependent on the configuration info
  2.  * in config.h. The idea is that configuration-dependent tables should
  3.  * be located here to avoid having to pepper lots of .c files with #ifdefs,
  4.  * requiring them to include config.h and be recompiled each time config.h
  5.  * is modified.
  6.  *
  7.  * Copyright 1991 Phil Karn, KA9Q
  8.  */
  9.  /* Mods by PA0GRI */
  10.  
  11. #include <stdio.h>
  12. #include <dos.h>
  13. #ifdef MSDOS
  14. #include <conio.h>
  15. #endif
  16. #include "global.h"
  17. #include "config.h"
  18. #include "mbuf.h"
  19. #include "timer.h"
  20. #include "proc.h"
  21. #include "iface.h"
  22. #include "ip.h"
  23. #include "tcp.h"
  24. #include "udp.h"
  25. #ifdef  ARCNET
  26. #include "arcnet.h"
  27. #endif
  28. #include "lapb.h"
  29. #include "ax25.h"
  30. #include "enet.h"
  31. #include "kiss.h"
  32. #include "netrom.h"
  33. #include "nr4.h"
  34. #include "pktdrvr.h"
  35. #include "ppp.h"
  36. #include "slip.h"
  37. #include "arp.h"
  38. #include "icmp.h"
  39. #include "hardware.h"   /***/
  40. #include "smtp.h"
  41. #include "usock.h"
  42. #include "cmdparse.h"
  43. #include "commands.h"
  44. #include "mailbox.h"
  45. #include "mailcli.h"
  46. #include "ax25mail.h"
  47. #include "nr4mail.h"
  48. #include "tipmail.h"
  49. #include "bootp.h"
  50. #include "daemon.h"
  51. #include "slhc.h"
  52. #include "rspf.h"
  53. #include "main.h"
  54.  
  55. static int dostart __ARGS((int argc,char *argv[],void *p));
  56. static int dostop __ARGS((int argc,char *argv[],void *p));
  57. static void network __ARGS((int,void *,void *));
  58.  
  59. #ifdef  NNTPS
  60. extern int donntpcli __ARGS((int argc,char *argv[],void *p));
  61. extern int nntp0 __ARGS((int argc,char *argv[],void *p));
  62. extern int nntp1 __ARGS((int argc,char *argv[],void *p));
  63. #endif
  64.  
  65. #ifdef  CONVERS
  66. int conv0 __ARGS((int argc,char *argv[],void *p));
  67. int conv1 __ARGS((int argc,char *argv[],void *p));
  68. #endif
  69.  
  70. #ifdef RLOGINSERVER
  71. int rlogin0 __ARGS((int argc,char *argv[],void *p));
  72. int rlogin1 __ARGS((int argc,char *argv[],void *p));
  73. #endif
  74.  
  75. #ifdef  AX25
  76. static void axip __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  77. char *dest,struct mbuf *bp,int mcast));
  78. static void axarp __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  79. char *dest,struct mbuf *bp,int mcast));
  80. static void axrarp __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  81. char *dest,struct mbuf *bp,int mcast));
  82. static void axnr __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  83. char *dest,struct mbuf *bp,int mcast));
  84. #endif
  85.  
  86. struct mbuf *Hopper;
  87. unsigned Nsessions = NSESSIONS;
  88.  
  89. /* Free memory threshold, below which things start to happen to conserve
  90.  * memory, like garbage collection, source quenching and refusing connects
  91.  */
  92. int32 Memthresh = MTHRESH;
  93.  
  94. #ifndef LINUX
  95. int Nibufs = NIBUFS;            /* Number of interrupt buffers */
  96. unsigned Ibufsize = IBUFSIZE;   /* Size of each interrupt buffer */
  97. #endif
  98.  
  99. /* Transport protocols atop IP */
  100. struct iplink Iplink[] = {
  101.     TCP_PTCL,       tcp_input,
  102.     UDP_PTCL,       udp_input,
  103.     ICMP_PTCL,      icmp_input,
  104. #ifdef ENCAP
  105.     IP_PTCL,        ipip_recv,
  106.     IP4_PTCL,       ipip_recv,
  107. #endif
  108. #ifdef  AXIP
  109.     AX25_PTCL,      axip_input,
  110. #endif
  111. #ifdef  RSPF
  112.     RSPF_PTCL,      rspf_input,
  113. #endif  /* RSPF */
  114.     0,              0
  115. };
  116.  
  117. /* Transport protocols atop ICMP */
  118. struct icmplink Icmplink[] = {
  119.     TCP_PTCL,       tcp_icmp,
  120.     0,              0
  121. };
  122.  
  123. /* ARP protocol linkages */
  124. struct arp_type Arp_type[NHWTYPES] = {
  125. #ifdef  NETROM
  126.     AXALEN, 0, 0, 0, 0, NULLCHAR, pax25, setcall,   /* ARP_NETROM */
  127. #else
  128.     0, 0, 0, 0, 0, NULLCHAR,NULL,NULL,
  129. #endif
  130.  
  131. #ifdef  ETHER
  132.     EADDR_LEN,IP_TYPE,ARP_TYPE,REVARP_TYPE,1,Ether_bdcst,pether,gether, /* ARP_ETHER */
  133. #else
  134.     0, 0, 0, 0, 0, NULLCHAR,NULL,NULL,
  135. #endif
  136.  
  137.     0, 0, 0, 0, 0, NULLCHAR,NULL,NULL,              /* ARP_EETHER */
  138.  
  139. #ifdef  AX25
  140.     AXALEN, PID_IP, PID_ARP, PID_RARP, 10, Ax25multi[0], pax25, setcall,
  141. #else
  142.     0, 0, 0, 0, 0, NULLCHAR,NULL,NULL,              /* ARP_AX25 */
  143. #endif
  144.  
  145.     0, 0, 0, 0, 0, NULLCHAR,NULL,NULL,              /* ARP_PRONET */
  146.  
  147.     0, 0, 0, 0, 0, NULLCHAR,NULL,NULL,              /* ARP_CHAOS */
  148.  
  149.     0, 0, 0, 0, 0, NULLCHAR,NULL,NULL,              /* ARP_IEEE802 */
  150.  
  151. #ifdef  ARCNET
  152.     AADDR_LEN, ARC_IP, ARC_ARP, 0, 1, ARC_bdcst, parc, garc, /* ARP_ARCNET */
  153. #else
  154.     0, 0, 0, 0, 0, NULLCHAR,NULL,NULL,
  155. #endif
  156.  
  157.     0, 0, 0, 0, 0, NULLCHAR,NULL,NULL,              /* ARP_APPLETALK */
  158. };
  159.  
  160. #ifdef  AX25
  161. /* Linkage to network protocols atop ax25 */
  162. struct axlink Axlink[] = {
  163.     PID_IP,         axip,
  164.     PID_ARP,        axarp,
  165. #ifdef RARP
  166.     PID_RARP,   axrarp,
  167. #endif
  168. #ifdef  NETROM
  169.     PID_NETROM,     axnr,
  170. #endif
  171.     PID_NO_L3,      axnl3,
  172.     0,              NULL,
  173. };
  174. #endif
  175.  
  176. #ifdef  MAILCLIENT
  177. struct daemon Mailreaders[] = {
  178. #ifdef  POP2CLIENT
  179.     "POP2",         2048,   pop2_job,
  180. #endif
  181. #ifdef  POP3CLIENT
  182.     "POP3",         2048,   pop3_job,
  183. #endif
  184.     NULLCHAR
  185. };
  186. #endif
  187.  
  188. #ifndef BOOTP
  189. int WantBootp = 0;
  190.  
  191. int
  192. bootp_validPacket(ip,bpp)
  193. struct ip *ip;
  194. struct mbuf **bpp;
  195. {
  196.     return 0;
  197. }
  198. #endif
  199.  
  200. #ifdef  MAILBOX
  201. void (*Listusers) __ARGS((int s)) = listusers;
  202. #else
  203. void (*Listusers) __ARGS((int s)) = NULL;
  204. #endif
  205.  
  206. #ifdef ETHER
  207. #define NWSTACK 2048
  208. #else
  209. #define NWSTACK 1024
  210. #endif
  211.  
  212. /* daemons to be run at startup time */
  213. struct daemon Daemons[] = {
  214.     "killer",       1024,   killer,
  215.     "timer",        1024,   timerproc,
  216.     "network",      NWSTACK,network,
  217.     "keyboard",     512,    keyboard,
  218. #ifndef UNIX
  219. #ifdef CONVERS
  220.     "gcollect",     512,    gcollect,
  221. #else
  222.     "gcollect",     256,    gcollect,
  223. #endif
  224. #endif
  225.     NULLCHAR,       0,      NULLVFP
  226. };
  227.  
  228. struct iftype Iftypes[] = {
  229.     /* This entry must be first, since Loopback refers to it */
  230.     "None",         NULL,           NULL,           NULL,
  231.     NULL,           CL_NONE,        0,
  232.  
  233. #ifdef  AX25
  234.     "AX25",         ax_send,        ax_output,      pax25,
  235.     setcall,        CL_AX25,        AXALEN,
  236. #endif
  237.  
  238. #ifdef  SLIP
  239.     "SLIP",         slip_send,      NULL,           NULL,
  240.     NULL,           CL_NONE,        0,
  241. #endif
  242.  
  243. #ifdef  ETHER
  244.     /* Note: NULL is specified for the scan function even though
  245.      * gether() exists because the packet drivers don't support
  246.      * address setting.
  247.      */
  248.     "Ethernet",     enet_send,      enet_output,    pether,
  249.     NULL,           CL_ETHERNET,    EADDR_LEN,
  250. #endif
  251.  
  252. #ifdef  NETROM
  253.     "NETROM",       nr_send,        NULL,           pax25,
  254.     setcall,        CL_NETROM,      AXALEN,
  255. #endif
  256.  
  257. #ifdef  SLFP
  258.     "SLFP",         pk_send,        NULL,           NULL,
  259.     NULL,           CL_NONE,        0,
  260. #endif
  261.  
  262. #ifdef  PPP
  263.     "PPP",          ppp_send,       ppp_output,     NULL,
  264.     NULL,           CL_PPP,         0,
  265. #endif
  266.  
  267.     NULLCHAR
  268. };
  269.  
  270. /* Command lookup and branch tables */
  271. struct cmds DFAR Cmds[] = {
  272.     /* The "go" command must be first */
  273.     "",             go,             0, 0, NULLCHAR,
  274. #ifndef AMIGA
  275. #ifdef SHELL
  276.     "!",            doshell,        0, 0, NULLCHAR,
  277. #endif
  278. #endif
  279. #ifdef FTPSESSION
  280.     "abort",    doabort,    0, 0, NULLCHAR,
  281. #endif
  282. #ifdef AMIGA
  283.     "amiga",        doamiga,        0, 0, NULLCHAR,
  284. #endif
  285. #if defined MAC && defined APPLETALK
  286.     "applestat",    doatstat,       0,      0, NULLCHAR,
  287. #endif
  288. #if defined AX25 || defined ETHER || defined APPLETALK
  289.     "arp",          doarp,          0, 0, NULLCHAR,
  290. #endif
  291. #ifdef ASY
  292.     "asystat",      doasystat,      0, 0, NULLCHAR,
  293. #endif
  294. #ifdef ATCMD
  295.     "at",       doat,       0, 0, NULLCHAR,
  296. #endif
  297.     "attach",       doattach,       0, 2,
  298.     "attach <hardware> <hw specific options>",
  299. #ifdef TTYLINKSERVER
  300.     "attended",     doattended,     0, 0, NULLCHAR,
  301. #endif
  302. #ifdef  AX25
  303. #ifdef AUTOROUTE
  304.     "autoroute",doax25autoroute, 0, 0, NULLCHAR,
  305. #endif /* AUTOROUTE */
  306.     "ax25",     doax25,     0, 0, NULLCHAR,
  307. #endif /* AX25 */
  308. #ifdef BBSSESSION
  309.     "bbs",      dotelnet,   1024, 0, NULLCHAR,
  310. #endif
  311. #ifdef  BOOTP
  312.     "bootp",    dobootp,    0, 0, NULLCHAR,
  313.     "bootpd",       bootpdcmd,      0, 0, NULLCHAR,
  314. #endif
  315. #ifdef BPQ
  316.     "bpqstat",  dobpqstat,  0,  0,  NULLCHAR,
  317. #endif
  318. #ifdef RLINE
  319.     "bulletin", dombrline,  0, 0, NULLCHAR,
  320. #endif
  321. /* This one is out of alpabetical order to allow abbreviation to "c" */
  322. #ifdef AX25SESSION
  323.     "connect",  doconnect,  1024, 3,
  324.     "connect <interface> <callsign>",
  325. #endif
  326. #if defined CALLCLI || defined SAMCALLB || defined QRZCALLB
  327.     "callbook", docallbook, 1024, 2, "callbook CALLSIGN",
  328. #endif
  329. #if defined(CALLSERVER) || defined(CALLCLI) || defined SAMCALLB || defined QRZCALLB
  330.     "callserver2", docallserver, 0, 0, NULLCHAR,
  331. #endif
  332. #if !defined(UNIX) && !defined(AMIGA)
  333. #ifdef DOSCMD
  334.     "cd",       docd,       0, 0, NULLCHAR,
  335. #endif
  336. #ifdef CALLSERVER
  337.     "cdrom", docdrom, 0, 0, NULLCHAR,
  338. #endif
  339. #endif
  340.     "close",        doclose,        0, 0, NULLCHAR,
  341.     "cls",  (int (*) ())    clrscr,      0, 0, NULLCHAR,
  342. #ifdef ASY
  343.     "comm",     doasycomm,  0, 3,"comm <interface> <text-string>",
  344. #endif
  345. #ifdef CONVERS
  346.     "convers",  doconvers,  0,  0, NULLCHAR,
  347. #endif
  348. #ifdef DOSCMD
  349.     "copy",     docopy,     0, 3,"copy <file> <newfile>",
  350. #endif
  351. /* This one is out of alpabetical order to allow abbreviation to "d" */
  352. #ifdef SESSIONS
  353.     "disconnect",   doclose,    0, 0, NULLCHAR,
  354. #endif
  355. #ifndef AMIGA
  356. #ifdef DIRSESSION
  357.     "dir",      dodir,      0, 0, NULLCHAR, /* note sequence */
  358. #endif
  359. #endif
  360. #ifdef DOSCMD
  361.     "delete",   dodelete,   0, 2, "delete <file>",
  362. #endif
  363.     "detach",   dodetach,   0, 2, "detach <interface>",
  364. #ifdef  DIALER
  365.     "dialer",       dodialer,       512, 2,
  366.     "dialer <iface> [<file> [<seconds> [<pings> [<hostid>]]]]",
  367. #endif
  368.     "domain",       dodomain,       0, 0, NULLCHAR,
  369. #ifdef  DRSI
  370.     "drsistat",     dodrstat,       0, 0, NULLCHAR,
  371. #endif
  372. #ifdef ALLCMD
  373.     "dump",     domdump,    0, 0, NULLCHAR,
  374. #endif
  375. #ifdef MAILERROR
  376.     "errors",   doerror,    0, 0, NULLCHAR,
  377. #endif
  378. #ifdef  HS
  379.     "hs",           dohs,           0, 0, NULLCHAR,
  380. #endif
  381. #ifdef  EAGLE
  382.     "eaglestat",    doegstat,       0, 0, NULLCHAR,
  383. #endif
  384.     "echo",         doecho,         0, 0, NULLCHAR,
  385.     "eol",          doeol,          0, 0, NULLCHAR,
  386. #if     (!defined(MSDOS) || defined(ESCAPE))
  387.     "escape",       doescape,       0, 0, NULLCHAR,
  388. #endif
  389. #ifdef  PC_EC
  390.     "etherstat",    doetherstat,    0, 0, NULLCHAR,
  391. #endif
  392.     "exit",         doexit,         0, 0, NULLCHAR,
  393. #ifdef EXPIRY
  394.     "expire",   doexpire,   0, 0, NULLCHAR,
  395. #endif
  396. #ifdef FINGERSESSION
  397.     "finger",   dofinger,   1024, 2, "finger name@host",
  398. #endif
  399. #ifdef ALLCMD
  400.     "fkey",         dofkey,         0, 0, NULLCHAR,
  401. #endif
  402. #ifdef FTPSESSION
  403.     "ftp",      doftp,      2048, 2, "ftp <address>",
  404.     "ftype",    doftype,    0, 0, NULLCHAR,
  405. #ifdef LZW
  406.     "ftpclzw",  doftpclzw,  0, 0, NULLCHAR,
  407.     "ftpslzw",  doftpslzw,  0, 0, NULLCHAR,
  408. #endif
  409. #endif
  410. #ifdef FTPSERVER
  411.     "ftptdisc", doftptdisc, 0, 0, NULLCHAR,
  412. #endif
  413. #ifdef HAPN
  414.     "hapnstat",     dohapnstat,     0, 0, NULLCHAR,
  415. #endif
  416.     "help",         dohelp,         0, 0, NULLCHAR,
  417.     "history",  dohistory,  0, 0, NULLCHAR,
  418. #ifdef HOPCHECKSESSION
  419.     "hop",          dohop,          0, 0, NULLCHAR,
  420. #endif
  421.     "hostname",     dohostname,     0, 0, NULLCHAR,
  422. #ifdef  HS
  423.     "hs",           dohs,           0, 0, NULLCHAR,
  424. #endif
  425.     "icmp",         doicmp,         0, 0, NULLCHAR,
  426.     "ifconfig",     doifconfig,     0, 0, NULLCHAR,
  427. #ifdef ALLCMD
  428.     "info",         doinfo,         0, 0, NULLCHAR,
  429. #endif
  430.     "index",        doindex,     2048, 2, "index <mailbox>",
  431.     "ip",           doip,           0, 0, NULLCHAR,
  432. #ifdef  MSDOS
  433.     "isat",         doisat,         0, 0, NULLCHAR,
  434. #endif
  435.     "kick",         dokick,         0, 0, NULLCHAR,
  436. #ifdef LOCK
  437.     "lock",         dolock,         0, 0, NULLCHAR,
  438. #endif
  439.     "log",      dolog,      0, 0, NULLCHAR,
  440. #ifdef LOOKSESSION
  441.     "look",     dolook,     1024, 2, "look <user|sock#>",
  442. #endif
  443. #ifdef LZW
  444.     "lzw",      dolzw,      0, 2, "lzw <mode|bits|trace>",
  445. #endif
  446. #ifdef ALLCMD
  447.     "mail",     dobmail,    0, 0, NULLCHAR,
  448. #endif
  449. #ifdef  MAILBOX
  450.     "mbox",         dombox,         0, 0, NULLCHAR,
  451. #endif
  452. #ifndef UNIX
  453.     "memory",       domem,          0, 0, NULLCHAR,
  454. #endif
  455. #ifdef DOSCMD
  456.     "mkdir",    domkd,      0, 2, "mkdir <directory>",
  457. #endif
  458. #ifdef  AX25
  459.     "mode",         domode,         0, 2, "mode <interface>",
  460. #endif
  461. #ifdef MORESESSION
  462.     "more",     domore,     0, 2, "more <file> [searchstring]",
  463. #endif
  464. #ifdef ALLCMD
  465.     "motd",         domotd,         0, 0, NULLCHAR,
  466. #endif
  467. #ifdef MSDOS
  468. #ifdef MULTITASK
  469.     "multitask",    dobackg,    0, 0, NULLCHAR,
  470. #endif
  471. #endif
  472. #ifdef NETROM
  473.     "netrom",       donetrom,       0, 0, NULLCHAR,
  474. #endif  /* NETROM */
  475. #if defined NNTP || defined NNTPS
  476.     "nntp",         donntp,         0, 0, NULLCHAR,
  477. #endif
  478. #ifdef NRS
  479.     "nrstat",       donrstat,       0, 0, NULLCHAR,
  480. #endif
  481. #ifdef EXPIRY
  482.     "oldbid",   dooldbids,  0, 0, NULLCHAR,
  483. #endif
  484.     "param",        doparam,        0, 2, "param <interface>",
  485.     "pause",        dopause,        0, 0, NULLCHAR,
  486. #ifdef PINGSESSION
  487.     "ping",         doping,         512, 2,
  488.     "ping <hostid> [<length> [<interval> [incflag]]]",
  489. #endif
  490. #ifdef PI
  491.     "pistatus",     dopistat,       0, 0, NULLCHAR,
  492. #endif
  493. #ifdef MAILCLIENT
  494.     "popmail",      domsread,       0, 0, NULLCHAR,
  495. #endif
  496. #ifdef PPP
  497.     "ppp",          doppp_commands, 0, 0, NULLCHAR,
  498. #endif
  499. #ifdef PRINTEROK
  500.     "print",    doprint,    512, 2, "print <file>",
  501. #endif
  502.     "prompt",   doprompt,   0, 0, NULLCHAR,
  503.     "ps",           ps,             0, 0, NULLCHAR,
  504. #if !defined(UNIX) && !defined(AMIGA)
  505. #ifdef DOSCMD
  506.     "pwd",      docd,       0, 0, NULLCHAR,
  507. #endif
  508. #endif
  509. #if (defined(AX25) || defined(ETHER))
  510. #ifdef RARP
  511.     "rarp",     dorarp,     0, 0, NULLCHAR,
  512. #endif /* RARP */
  513. #endif
  514. #ifdef RDATE
  515.     "rdate",    dordate,    0, 0, NULLCHAR,
  516. #endif
  517. #ifdef ALLCMD
  518.     "record",   dorecord,   0, 0, NULLCHAR,
  519. #endif
  520.     "remote",   doremote,   0, 3, "remote [-p port] [-k key] [-a kickaddr] <address> exit|reset|kick",
  521. #ifdef DOSCMD
  522.     "rename",   dorename,   0, 3, "rename <oldfile> <newfile>",
  523. #endif
  524. #ifdef REPEATSESSION
  525.     "repeat",   dorepeat, 512, 3, "repeat <interval> <command> [args...]",
  526. #endif
  527.     "reset",    doreset,    0, 0, NULLCHAR,
  528.     "rewrite",  dorewrite,  0, 2, "rewrite <address>",
  529. #ifdef  RIP
  530.     "rip",          dorip,          0, 0, NULLCHAR,
  531. #endif
  532. #ifdef RLOGINSESSION
  533.     "rlogin",       dorlogin,       2048, 2, "rlogin <address>",
  534. #endif
  535. #ifdef DOSCMD
  536.     "rmdir",    dormd,      0, 2, "rmdir <directory>",
  537. #endif
  538.     "route",    doroute,    0, 0, NULLCHAR,
  539. #ifdef  RSPF
  540.     "rspf",         dorspf,         0, 0, NULLCHAR,
  541. #endif  /* RSPF */
  542. #ifdef SESSIONS
  543.     "session",      dosession,      0, 0, NULLCHAR,
  544. #endif
  545. #ifdef  SCC
  546.     "sccstat",      dosccstat,      0, 0, NULLCHAR,
  547. #endif
  548. #if     !defined(AMIGA)
  549. #ifdef SHELL
  550.     "shell",    doshell,    0, 0, NULLCHAR,
  551. #endif
  552. #endif
  553.     "skick",    dokicksocket,0,2, "skick <socket#>",
  554.     "smtp",     dosmtp,     0, 0, NULLCHAR,
  555.     "socket",       dosock,         0, 0, NULLCHAR,
  556.     "source",       dosource,       0, 2, "source <filename>",
  557. #ifdef SERVERS
  558.     "start",        dostart,        0, 2, "start <servername>",
  559.     "stop",         dostop,         0, 2, "stop <servername>",
  560. #endif
  561.     "status",   dostatus,   0, 0, NULLCHAR,
  562. #if defined  AX25SESSION && defined SPLITSCREEN
  563.     "split",    doconnect,  1024, 3, "split <interface> <callsign>",
  564. #endif
  565.     "tcp",      dotcp,      0, 0, NULLCHAR,
  566. #ifdef ALLCMD
  567.     "tail",     dotail,     0, 2, "tail <filename>",
  568.     "taillog",  dotaillog,  0, 0, NULLCHAR,
  569. #endif
  570. #ifdef TELNETSESSION
  571.     "telnet",   dotelnet,   1024, 2, "telnet <address> [port]",
  572. #endif
  573. #ifdef TTYLINKSESSION
  574.     "ttylink",  dotelnet,  1024, 2, "ttylink <address> [port]",
  575. #endif
  576. #ifdef  MAILBOX
  577.     "third-party",  dothirdparty,   0, 0, NULLCHAR,
  578. #endif
  579. #ifdef TIPSESSION
  580.     "tip",      dotip,      256, 2, "tip <iface (asyc only!)>",
  581. #endif
  582. #ifdef  PACKETWIN
  583.     "tsync_stat",   do_tsync_stat,  0, 0, NULLCHAR,
  584.     "tsydump",              do_tsync_dump,  0, 2, "tsydump <channel>",
  585. #endif
  586. #ifdef  TRACE
  587.     "trace",        dotrace,        0, 0, NULLCHAR,
  588.     "strace",   dostrace,   0, 0, NULLCHAR,
  589. #endif
  590.     "udp",          doudp,          0, 0, NULLCHAR,
  591. #ifdef ALLCMD
  592.     "upload",   doupload,   0, 0, NULLCHAR,
  593. #endif
  594. #ifdef  MSDOS
  595. #ifdef ALLCMD
  596. #ifdef SWATCH
  597.     "watch",    doswatch,   0, 0, NULLCHAR,
  598. #endif
  599. #endif
  600.     "watchdog", dowatchdog, 0, 0, NULLCHAR,
  601. #endif
  602.     "write",    dowrite,    0, 3, "write <user|sock#> <msg>",
  603. #ifdef MAILBOX
  604.     "writeall", dowriteall, 0, 2, "writeall <msg>",
  605. #endif
  606.     "?",        dohelp,     0, 0, NULLCHAR,
  607.     NULLCHAR,       NULLFP,         0, 0,
  608.     "Unknown command; type \"?\" for list",
  609. };
  610.  
  611. extern int at_attach();
  612.  
  613. /* List of supported hardware devices */
  614. struct cmds DFAR Attab[] = {
  615.  
  616. #ifdef  PC_EC
  617.     /* 3-Com Ethernet interface */
  618.     "3c500", ec_attach, 0, 7,
  619.     "attach 3c500 <address> <vector> arpa <label> <buffers> <mtu> [ip_addr]",
  620. #endif
  621.  
  622. #ifdef  ASY
  623.     /* Ordinary PC asynchronous adaptor */
  624.     "asy",  asy_attach, 0, 8,
  625.     "attach asy <address> <vector> "
  626.  
  627. #ifdef SLIP
  628.     "slip"
  629. #endif
  630.  
  631. #ifdef AX25
  632. #ifdef SLIP
  633.     "|"
  634. #endif
  635.     "ax25"
  636. #endif
  637.  
  638. #ifdef NRS
  639. #if ((defined SLIP) || (defined AX25))
  640.     "|"
  641. #endif
  642.     "nrs"
  643. #endif
  644.  
  645. #ifdef POLLEDKISS
  646. #if ((defined SLIP) || (defined AX25) || (defined NRS))
  647.     "|"
  648. #endif
  649.     "|pkiss"
  650. #endif
  651.  
  652. #ifdef PPP
  653. #if ((defined SLIP) || (defined AX25) || (defined NRS) || (defined POLLEDKISS))
  654.     "|"
  655. #endif
  656.     "|ppp"
  657. #endif
  658.  
  659.     " <label> <buffers> <mtu> <speed> [options]",
  660. #endif  /* ASY */
  661.  
  662. #ifdef BPQ
  663.     /* g8bpq_host */
  664.     "bpq", bpq_attach, 0, 3,
  665.     "attach bpq init <vec> <stream>\n"
  666.     "attach bpq <port> <label> [mtu] [callsign]",
  667. #endif
  668.  
  669. #ifdef  KISS
  670.     /* Multi-port KISS interface piggy-backing on ASY interface. */
  671.     "kiss", kiss_attach, 0, 4,
  672.     "attach kiss <asy_interface_label> <port> <label> [mtu]",
  673. #endif  /* KISS */
  674.  
  675. #ifdef  PC100
  676.     /* PACCOMM PC-100 8530 HDLC adaptor */
  677.     "pc100", pc_attach, 0, 8,
  678.     "attach pc100 <address> <vector> ax25 <label> <buffers>\
  679.     <mtu> <speed> [ip_addra] [ip_addrb]",
  680. #endif
  681.  
  682. #ifdef  DRSI
  683.     /* DRSI PCPA card in low speed mode */
  684.     "drsi", dr_attach, 0, 8,
  685.     "attach drsi <address> <vector> ax25 <label> <bufsize> <mtu>\
  686.     <chan a speed> <chan b speed> [ip addr a] [ip addr b]",
  687. #endif
  688.  
  689. #ifdef  EAGLE
  690.     /* EAGLE RS-232C 8530 HDLC adaptor */
  691.     "eagle", eg_attach, 0, 8,
  692.     "attach eagle <address> <vector> ax25 <label> <buffers>\
  693.     <mtu> <speed> [ip_addra] [ip_addrb]",
  694. #endif
  695.  
  696. #ifdef  HAPN
  697.     /* Hamilton Area Packet Radio (HAPN) 8273 HDLC adaptor */
  698.     "hapn", hapn_attach, 0, 8,
  699.     "attach hapn <address> <vector> ax25 <label> <rx bufsize>\
  700.     <mtu> csma|full [ip_addr]",
  701. #endif
  702.  
  703. #ifdef  APPLETALK
  704.     /* Macintosh AppleTalk */
  705.     "0", at_attach, 0, 7,
  706.     "attach 0 <protocol type> <device> arpa <label> <rx bufsize> <mtu> [ip_addr]",
  707. #endif
  708.  
  709. #ifdef NETROM
  710.     /* fake netrom interface */
  711.     "netrom", nr_attach, 0, 1,
  712.     "attach netrom [ip_addr]",
  713. #endif
  714.  
  715. #ifdef  PACKET
  716.     /* FTP Software's packet driver spec */
  717.     "packet", pk_attach, 0, 4,
  718.     "attach packet <int#> <label> <buffers> <mtu> [ip_addr]",
  719. #endif
  720.  
  721. #ifdef  HS
  722.     /* Special high speed driver for DRSI PCPA or Eagle cards */
  723.     "hs", hs_attach, 0, 7,
  724.     "attach hs <address> <vector> ax25 <label> <buffers> <mtu>\
  725.     <txdelay> <persistence> [ip_addra] [ip_addrb]",
  726. #endif
  727.  
  728. #ifdef  PI
  729.     /* Special high speed driver for PI 8530 HDLC adapter */
  730.     "pi", pi_attach, 0, 8,
  731.     "attach pi <address> <vector> <dmachannel> ax25 <label> <buffers>\
  732.     <mtu> <speed a> <speed b> [ip_addra] [ip_addrb]",
  733. #endif
  734.  
  735. #ifdef SCC
  736.     "scc", scc_attach, 0, 7,
  737.     "attach scc <devices> init <addr> <spacing> <Aoff> <Boff> <Dataoff>\n"
  738.     "   <intack> <vec> [p]<clock> [hdwe] [param]\n"
  739.     "attach scc <chan> slip|kiss|nrs|ax25 <label> <mtu> <speed> <bufsize> [call] ",
  740. #endif
  741.  
  742. #ifdef  PACKETWIN
  743.     /* Gracilis PackeTwin */
  744.     "tsync", tsync_attach, 0, 11,
  745.     "attach tsync <chan> <vec> <iobase> <hdx|fdx> <dma|ints> <rxdmachan> <name> <rxsize> <txsize> <speed> [txclk] [rxclk] [nrz|nrzi] [ipaddr] [#rxbufs]",
  746. #endif
  747.  
  748. #ifdef AXIP
  749.     "axip",axip_attach, 0, 4,
  750.     "attach axip <name> <mtu> <remote-hostid> [callsign]",
  751. #endif
  752.  
  753.     NULLCHAR,
  754. };
  755.  
  756. #ifndef LINUX
  757.  
  758. /* Functions to be called on each clock tick */
  759. void (*Cfunc[]) __ARGS((void)) = {
  760.     pctick, /* Call PC-specific stuff to keep time */
  761.     kbint,  /* Necessary because there's no hardware keyboard interrupt */
  762.     refiq,  /* Replenish interrupt pool */
  763. #ifdef  ASY
  764.     asytimer,
  765. #endif
  766. #ifdef  SCC
  767.     scctimer,
  768. #endif
  769. #ifdef BPQ
  770.     bpqtimer,
  771. #endif
  772.     NULL,
  773. };
  774.  
  775. /* Entry points for garbage collection */
  776. void (*Gcollect[]) __ARGS((int)) = {
  777.     tcp_garbage,
  778.     ip_garbage,
  779.     udp_garbage,
  780.     st_garbage,
  781. #ifdef  AX25
  782.     lapb_garbage,
  783. #endif
  784. #ifdef  NETROM
  785.     nr_garbage,
  786. #endif
  787.     NULL
  788. };
  789.  
  790. /* Functions to be called at shutdown */
  791. void (*Shutdown[])() = {
  792. #ifdef SCC
  793.     sccstop,
  794. #endif
  795.     uchtimer,       /* Unlink timer handler from timer chain */
  796.     NULLVFP,
  797. };
  798.  
  799. #endif /* LINUX */
  800.  
  801. /* Packet tracing stuff */
  802. #ifdef  TRACE
  803. #include "trace.h"
  804.  
  805. extern int at_forus();
  806. extern void at_dump();
  807.  
  808. /* Protocol tracing function pointers. Matches list of class definitions
  809.  * in pktdrvr.h.
  810.  */
  811. struct trace Tracef[] = {
  812.     NULLFP,         ip_dump,        /* CL_NONE */
  813.  
  814. #ifdef  ETHER                           /* CL_ETHERNET */
  815.     ether_forus,    ether_dump,
  816. #else
  817.     NULLFP,         NULLVFP,
  818. #endif  /* ETHER */
  819.  
  820.     NULLFP,         NULLVFP,        /* CL_PRONET_10 */
  821.     NULLFP,         NULLVFP,        /* CL_IEEE8025 */
  822.     NULLFP,         NULLVFP,        /* CL_OMNINET */
  823.  
  824. #ifdef  APPLETALK
  825.     at_forus,       at_dump,        /* CL_APPLETALK */
  826. #else
  827.     NULLFP,         NULLVFP,
  828. #endif  /* APPLETALK */
  829.  
  830. #ifdef VJCOMPRESS
  831.     NULLFP,         sl_dump,        /* CL_SERIAL_LINE */
  832. #else
  833.     NULLFP,         ip_dump,        /* CL_SERIAL_LINE */
  834. #endif
  835.     NULLFP,         NULLVFP,        /* CL_STARLAN */
  836.  
  837. #ifdef  ARCNET
  838.     arc_forus,      arc_dump,       /* CL_ARCNET */
  839. #else
  840.     NULLFP,         NULLVFP,
  841. #endif  /* ARCNET */
  842.  
  843. #ifdef  AX25
  844.     ax_forus,       ax25_dump,      /* CL_AX25 */
  845. #else
  846.     NULLFP,         NULLVFP,
  847. #endif  /* AX25 */
  848.  
  849. #ifdef  AX25                           /* CL_KISS */
  850.     ki_forus,       ki_dump,
  851. #else
  852.     NULLFP,         NULLVFP,
  853. #endif  /* KISS */
  854.  
  855.     NULLFP,         NULLVFP,        /* CL_IEEE8023 */
  856.     NULLFP,         NULLVFP,        /* CL_FDDI */
  857.     NULLFP,         NULLVFP,        /* CL_INTERNET_X25 */
  858.     NULLFP,         NULLVFP,        /* CL_LANSTAR */
  859. #ifdef  SLFP
  860.     NULLFP,         ip_dump,        /* CL_SLFP */
  861. #else
  862.     NULLFP,         NULLVFP,
  863. #endif  /* SLFP */
  864.  
  865. #ifdef  NETROM                          /* CL_NETROM */
  866.     NULLFP,         ip_dump,
  867. #else
  868.     NULLFP,         NULLVFP,
  869. #endif
  870.  
  871. #ifdef PPP
  872.     NULLFP,         ppp_dump,       /* CL_PPP */
  873. #else
  874.     NULLFP,         NULLVFP,
  875. #endif /* PPP */
  876. };
  877.  
  878. #else
  879.  
  880. /* Stub for packet dump function */
  881. void
  882. dump(iface,direction,type,bp)
  883. struct iface *iface;
  884. int direction;
  885. unsigned type;
  886. struct mbuf *bp;
  887. {
  888. }
  889. void
  890. raw_dump(iface,direction,bp)
  891. struct iface *iface;
  892. int direction;
  893. struct mbuf *bp;
  894. {
  895. }
  896.  
  897. #endif  /* TRACE */
  898.  
  899.  
  900. #ifdef  AX25
  901. #ifdef AUTOROUTE
  902. /* G4JEC's automatic ARP & Route resolution code primitive. */
  903. extern void ax25eavesdrop(struct iface * iface,
  904. char *source, char * dest,
  905. struct mbuf * bp);
  906.  
  907. extern int Ax25_autoroute;
  908. #endif /* AUTOROUTE */
  909.  
  910. /* Hooks for passing incoming AX.25 data frames to network protocols */
  911. void
  912. axip(iface,axp,src,dest,bp,mcast)
  913. struct iface *iface;
  914. struct ax25_cb *axp;
  915. char *src;
  916. char *dest;
  917. struct mbuf *bp;
  918. int mcast;
  919. {
  920. #ifdef AUTOROUTE
  921.     struct mbuf *nbp;
  922.  
  923.     if(Ax25_autoroute) {
  924.         dup_p(&nbp, bp, 0, len_p(bp));
  925.         (void) ax25eavesdrop(iface,src,dest,nbp);
  926.         free_p(nbp);
  927.     }
  928. #endif
  929.     (void)ip_route(iface,bp,mcast);
  930. }
  931.  
  932. static void
  933. axarp(iface,axp,src,dest,bp,mcast)
  934. struct iface *iface;
  935. struct ax25_cb *axp;
  936. char *src;
  937. char *dest;
  938. struct mbuf *bp;
  939. int mcast;
  940. {
  941.     (void)arp_input(iface,bp);
  942. }
  943.  
  944. #ifdef RARP
  945. static void
  946. axrarp(iface,axp,src,dest,bp,mcast)
  947. struct iface *iface;
  948. struct ax25_cb *axp;
  949. char *src;
  950. char *dest;
  951. struct mbuf *bp;
  952. int mcast;
  953. {
  954.     (void)rarp_input(iface,bp);
  955. }
  956. #endif /* RARP */
  957.  
  958. #ifdef  NETROM
  959. static void
  960. axnr(iface,axp,src,dest,bp,mcast)
  961. struct iface *iface;
  962. struct ax25_cb *axp;
  963. char *src;
  964. char *dest;
  965. struct mbuf *bp;
  966. int mcast;
  967. {
  968.     if(!mcast)
  969.         nr_route(bp,axp);
  970.     else
  971.         nr_nodercv(iface,src,bp);
  972. }
  973.  
  974. #endif  /* NETROM */
  975. #endif  /* AX25 */
  976.  
  977. #ifndef RIP
  978. /* Stub for routing timeout when RIP is not configured -- just remove entry */
  979. void
  980. rt_timeout(s)
  981. void *s;
  982. {
  983.     struct route *stale = (struct route *)s;
  984.  
  985.     rt_drop(stale->target,stale->bits);
  986. }
  987. #endif
  988.  
  989. #ifdef  SERVERS
  990. #define SSTACK 160      /* servers stack size */
  991. /* "start" and "stop" subcommands */
  992. static struct cmds DFAR Startcmds[] = {
  993. #ifdef AX25SERVER
  994.     "ax25",         ax25start,      SSTACK, 0, NULLCHAR,
  995. #endif
  996. #if defined CALLSERVER || defined SAMCALLB || defined QRZCALLB
  997.     "callbook",     cdbstart,       SSTACK, 0, NULLCHAR,
  998. #endif
  999. #ifdef  CONVERS
  1000.     "convers",      conv1,          0, 0, NULLCHAR,
  1001. #endif
  1002. #ifdef DISCARDSERVER
  1003.     "discard",      dis1,           0, 0, NULLCHAR,
  1004. #endif
  1005. #ifdef ECHOSERVER
  1006.     "echo",         echo1,          0, 0, NULLCHAR,
  1007. #endif
  1008. #ifdef FINGERSERVER
  1009.     "finger",       finstart,       0, 0, NULLCHAR,
  1010. #endif
  1011. #ifdef FTPSERVER
  1012.     "ftp",          ftpstart,       0, 0, NULLCHAR,
  1013. #endif
  1014. #if defined(MBFWD) && defined(MAILBOX)
  1015.     "forward",      fwdstart,       2048,0, NULLCHAR,
  1016. #endif
  1017. #ifdef NETROMSERVER
  1018.     "netrom",       nr4start,       SSTACK, 0, NULLCHAR,
  1019. #endif
  1020. #ifdef  NNTPS
  1021.     "nntp",         nntp1,          0, 0, NULLCHAR,
  1022. #endif
  1023. #ifdef  POP2SERVER
  1024.     "pop2",         pop2start,      0, 0, NULLCHAR,
  1025. #endif
  1026. #ifdef  POP3SERVER
  1027.     "pop3",         pop3start,      0, 0, NULLCHAR,
  1028. #endif
  1029. #ifdef  RIP
  1030.     "rip",          doripinit,      0,   0, NULLCHAR,
  1031. #endif
  1032. #ifdef RLOGINSERVER
  1033.        "rlogin",       rlogin1,   SSTACK, 0, NULLCHAR,
  1034. #endif
  1035. #ifdef SMTPSERVER
  1036.     "smtp",         smtp1,          0, 0, NULLCHAR,
  1037. #endif
  1038. #ifdef TELNETSERVER
  1039.     "telnet",       telnet1,        0, 0, NULLCHAR,
  1040. #endif
  1041. #ifdef TIPSERVER
  1042.     "tip",          tipstart,       384, 2, "start tip <interface>",
  1043. #endif
  1044. #ifdef  RDATE
  1045.     "time",         time1,          0, 0, NULLCHAR,
  1046. #endif
  1047. #ifdef TTYLINKSERVER
  1048.     "ttylink",      ttylstart,      0, 0, NULLCHAR,
  1049. #endif
  1050. #ifdef REMOTESERVER
  1051.     "remote",       rem1,           768, 0, NULLCHAR,
  1052. #endif
  1053.     NULLCHAR,
  1054. };
  1055.  
  1056. static struct cmds DFAR Stopcmds[] = {
  1057. #ifdef AX25SERVER
  1058.     "ax25",         ax250,          0, 0, NULLCHAR,
  1059. #endif
  1060. #if defined CALLSERVER || defined SAMCALLB || defined QRZCALLB
  1061.     "callbook",     cdb0,           0, 0, NULLCHAR,
  1062. #endif
  1063. #ifdef  CONVERS
  1064.     "convers",  conv0,      0, 0, NULLCHAR,
  1065. #endif
  1066. #ifdef DISCARDSERVER
  1067.     "discard",  dis0,       0, 0, NULLCHAR,
  1068. #endif
  1069. #ifdef ECHOSERVER
  1070.     "echo",         echo0,          0, 0, NULLCHAR,
  1071. #endif
  1072. #ifdef FINGERSERVER
  1073.     "finger",   fin0,       0, 0, NULLCHAR,
  1074. #endif
  1075. #ifdef FTPSERVER
  1076.     "ftp",          ftp0,           0, 0, NULLCHAR,
  1077. #endif
  1078. #if defined(MBFWD) && defined(MAILBOX)
  1079.     "forward",  fwd0,       0, 0, NULLCHAR,
  1080. #endif
  1081. #ifdef NETROMSERVER
  1082.     "netrom",       nr40,           0, 0, NULLCHAR,
  1083. #endif
  1084. #ifdef  NNTPS
  1085.     "nntp",     nntp0,      0, 0, NULLCHAR,
  1086. #endif
  1087. #ifdef  POP2SERVER
  1088.     "pop2",         pop2stop,       0, 0, NULLCHAR,
  1089. #endif
  1090. #ifdef  POP3SERVER
  1091.     "pop3",         pop3stop,       0, 0, NULLCHAR,
  1092. #endif
  1093. #ifdef  RIP
  1094.     "rip",          doripstop,      0, 0, NULLCHAR,
  1095. #endif
  1096. #ifdef RLOGINSERVER
  1097.         "rlogin",       rlogin0,        0, 0, NULLCHAR,
  1098. #endif
  1099. #ifdef SMTPSERVER
  1100.     "smtp",         smtp0,          0, 0, NULLCHAR,
  1101. #endif
  1102. #ifdef TELNETSERVER
  1103.     "telnet",       telnet0,        0, 0, NULLCHAR,
  1104. #endif
  1105. #ifdef TIPSERVER
  1106.     "tip",      tip0,       0, 2, "stop tip <interface>",
  1107. #endif
  1108. #ifdef  RDATE
  1109.     "time",     time0,      0, 0, NULLCHAR,
  1110. #endif
  1111. #ifdef TTYLINKSERVER
  1112.     "ttylink",  ttyl0,      0, 0, NULLCHAR,
  1113. #endif
  1114. #ifdef REMOTESERVER
  1115.     "remote",   rem0,       0, 0, NULLCHAR,
  1116. #endif
  1117.     NULLCHAR,
  1118.  
  1119. };
  1120.  
  1121. /* TCP port numbers to be considered "interactive" by the IP routing
  1122.  * code and given priority in queueing
  1123.  */
  1124. int Tcp_interact[] = {
  1125.     IPPORT_FTP, /* FTP control (not data!) */
  1126.     IPPORT_TELNET,  /* Telnet */
  1127.     IPPORT_CONVERS, /* Convers */
  1128.     IPPORT_XCONVERS,    /* LZW Convers */
  1129.     IPPORT_TTYLINK,     /* Tty link */
  1130.     IPPORT_RLOGIN,      /* BSD rlogin */
  1131.     IPPORT_MTP,         /* Secondary telnet */
  1132.     -1
  1133. };
  1134.  
  1135. static int
  1136. dostart(argc,argv,p)
  1137. int argc;
  1138. char *argv[];
  1139. void *p;
  1140. {
  1141.     int ret,insave,outsave;
  1142.  
  1143.     insave = Curproc->input;
  1144.     outsave = Curproc->output;
  1145.     Curproc->input = Cmdpp->input;
  1146.     Curproc->output = Cmdpp->output;
  1147.  
  1148.     ret = subcmd(Startcmds,argc,argv,p);
  1149.  
  1150.     Curproc->input = insave;
  1151.     Curproc->output = outsave;
  1152.     return ret;
  1153. }
  1154.  
  1155. static int
  1156. dostop(argc,argv,p)
  1157. int argc;
  1158. char *argv[];
  1159. void *p;
  1160. {
  1161.     return subcmd(Stopcmds,argc,argv,p);
  1162. }
  1163. #endif  /* SERVERS */
  1164.  
  1165. /* Various configuration-dependent functions */
  1166.  
  1167. /* put mbuf into Hopper for network task
  1168.  * returns 0 if OK
  1169.  */
  1170. int
  1171. net_route(ifp, type, bp)
  1172. struct iface *ifp;
  1173. int type;
  1174. struct mbuf *bp;
  1175. {
  1176.     struct mbuf *nbp;
  1177.     struct phdr phdr;
  1178.  
  1179.     phdr.iface = ifp;
  1180.     phdr.type = type;
  1181.  
  1182.     if ((nbp = pushdown(bp,sizeof(phdr))) == NULLBUF ){
  1183.         return -1;
  1184.     }
  1185.     memcpy( &nbp->data[0],(char *)&phdr,sizeof(phdr));
  1186.     enqueue(&Hopper,nbp);
  1187.     /* Especially on slow machines, serial I/O can be quite
  1188.      * compute intensive, so release the machine before we
  1189.      * do the next packet.  This will allow this packet to
  1190.      * go on toward its ultimate destination. [Karn]
  1191.      */
  1192.     pwait(NULL);
  1193.     return 0;
  1194. }
  1195.  
  1196. /* Process packets in the Hopper */
  1197. static void
  1198. network(i,v1,v2)
  1199. int i;
  1200. void *v1;
  1201. void *v2;
  1202. {
  1203.     struct mbuf *bp;
  1204.     struct phdr phdr;
  1205.     int i_state;
  1206.  
  1207.     loop:
  1208. #ifndef LINUX
  1209.     refiq();        /* Replenish interrupt buffer pool */
  1210. #endif
  1211.  
  1212.     i_state = dirps();
  1213.     while(Hopper == NULLBUF)
  1214.         pwait(&Hopper);
  1215.  
  1216.     /* this is silly, first we turn ints on, then off again...? -WG7J */
  1217.     /* Process the input packet */
  1218.     /*
  1219.     bp = dequeue(&Hopper);
  1220.      */
  1221.  
  1222.     bp = Hopper;
  1223.     Hopper = Hopper->anext;
  1224.     bp->anext = NULLBUF;
  1225.  
  1226.     restore(i_state);
  1227.  
  1228.     pullup(&bp,(char *)&phdr,sizeof(phdr));
  1229.     if(phdr.iface != NULLIF){
  1230.         phdr.iface->rawrecvcnt++;
  1231.         phdr.iface->lastrecv = secclock();
  1232.     }
  1233. #ifdef TRACE
  1234.     dump(phdr.iface,IF_TRACE_IN,phdr.type,bp);
  1235. #endif
  1236.     switch(phdr.type){
  1237. #if((defined KISS) || (defined AX25))
  1238.         case CL_KISS:
  1239.             kiss_recv(phdr.iface,bp);
  1240.             break;
  1241. #endif
  1242. #ifdef  AX25
  1243.         case CL_AX25:
  1244.             ax_recv(phdr.iface,bp);
  1245.             break;
  1246. #endif
  1247. #ifdef  ETHER
  1248.         case CL_ETHERNET:
  1249.             eproc(phdr.iface,bp);
  1250.             break;
  1251. #endif
  1252. #ifdef ARCNET
  1253.         case CL_ARCNET:
  1254.             aproc(phdr.iface,bp);
  1255.             break;
  1256. #endif
  1257. #ifdef PPP
  1258.         case CL_PPP:
  1259.             ppp_proc(phdr.iface,bp);
  1260.             break;
  1261. #endif
  1262.     /* These types have no link layer protocol at the point when they're
  1263.      * put in the hopper, so they can be handed directly to IP. The
  1264.      * separate types are just for user convenience when running the
  1265.      * "iface" command.
  1266.      */
  1267.         case CL_NONE:
  1268.         case CL_SERIAL_LINE:
  1269.         case CL_SLFP:
  1270.             ip_route(phdr.iface,bp,0);
  1271.             break;
  1272.         default:
  1273.             free_p(bp);
  1274.             break;
  1275.     }
  1276.     /* Let everything else run - this keeps the system from wedging
  1277.      * when we're hit by a big burst of packets
  1278.      */
  1279.     pwait(NULL);
  1280.     goto loop;
  1281. }
  1282.  
  1283. #ifdef notdef
  1284.  
  1285. /*
  1286.  * General purpose interface transmit task, one for each device that can
  1287.  * send IP datagrams. It waits on the interface's IP output queue (outq),
  1288.  * extracts IP datagrams placed there in priority order by ip_route(),
  1289.  * and sends them to the device's send routine.
  1290.  */
  1291. void
  1292. if_tx(dev,arg1,unused)
  1293. int dev;
  1294. void *arg1;
  1295. void *unused;
  1296. {
  1297.     struct mbuf *bp;    /* Buffer to send */
  1298.     struct iface *iface;    /* Pointer to interface control block */
  1299.     struct qhdr qhdr;
  1300.  
  1301.     iface = arg1;
  1302.     for(;;){
  1303.         while(iface->outq == NULLBUF)
  1304.             pwait(&iface->outq);
  1305.  
  1306.         iface->txbusy = 1;
  1307.         bp = dequeue(&iface->outq);
  1308.         pullup(&bp,(char *)&qhdr,sizeof(qhdr));
  1309.         (*iface->send)(bp,iface,qhdr.gateway,qhdr.tos);
  1310.         iface->txbusy = 0;
  1311.  
  1312.         /* Let other tasks run, just in case send didn't block */
  1313.         pwait(NULL);
  1314.     }
  1315. }
  1316.  
  1317. #endif
  1318.